﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;

public class BattleEvent: Singleton<BattleEvent>
{
    //object int 当前回合数
    public const string Eevent_Fresh_Round = "event_01";
    //object int 左边军队的当前兵力
    public const string Eevent_Fresh_LeftHp = "event_02";
    //object int 右边军队的当前兵力
    public const string Eevent_Fresh_RightHp = "event_03";
    //object BattleEv_FreshHero 英雄信息
    public const string Event_Fresh_Hero = "event_04";

    public const string Event_Fresh_Buff = "event_05";
    public const string Event_Fresh_Content = "event_06";

    public Dictionary<string, List<Action<string, object>>> dic_Center = new Dictionary<string, List<Action<string, object>>>();

    public void AddEvent(string eventId,Action<string,object> func)
    {
        if (!dic_Center.ContainsKey(eventId))
            dic_Center[eventId] = new List<Action<string, object>>();

        if (!dic_Center[eventId].Contains(func))
            dic_Center[eventId].Add(func);
    }

    public void DelEvent(string eventId,Action<string,object> func)
    {
        if (dic_Center[eventId] != null)
        {
            if (dic_Center[eventId].Contains(func))
            {
                dic_Center[eventId].Remove(func);
            }
        }
    }

    public void BroadcastEvent(string eventId,object par)
    {
        if (dic_Center[eventId] != null)
        {
            for(int i = 0; i < dic_Center[eventId].Count; i++)
            {
                if (dic_Center[eventId][i] != null)
                {
                    dic_Center[eventId][i](eventId, par);
                }
            }
        }
    }
}

/// <summary>
/// 刷新部队信息用到的参数结构
/// </summary>
public class BattleEv_FreshHero
{
    public int index;
    public int isLeft;
    public int curHp;
}

/// <summary>
/// 刷新Buf用到的参数
/// </summary>
public class BattleEv_FreshBuf
{
    // 格式 [标题] 内容
    // [强攻] 英雄攻击力+99
    // [强攻] 英雄防御力+88(持续3回合)

    //[**]
    public string title;
    //....
    public string content;
}


